<?php
namespace app\admin\model;
use think\Model;
class Enrollment extends Model
{
    //性别 gender 属性修改属
    // protected function setGenderAttr($value,$data)
    // {
    //     return '男' == $data['gender'] ? 0:1;
    // }

    // school_id读取器
    // protected function getSchoolidAttr($school_id)
    // {
    //     return $school_id == 0 ? '本校':'分校';
    // }

    // protected function getGenderAttr($value,$data)
    // {
    //     return 0 == $data['gender'] ? '男':'女';
    // }

    protected $type = [
        'enrollment_date'  =>  'timestamp',
    ];

    protected $insert = ['enrollment_date'];   
    
    protected function setEnrollmentDateAttr()
    {
        return time();
    }

    public function student()
    {
        return $this->belongsTo('student','stu_id');
    }

    public function course()
    {
        return $this->belongsTo('course');
    }
}